package com.ambow.core.base;import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config  {
    @Bean
    public Docket adminApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("adminApi").select().paths(Predicates.and(PathSelectors.regex("/admin/.*"))).build().apiInfo(adminInfo());
//        return new Docket(DocumentationType.SWAGGER_2).groupName("adminApi").apiInfo(adminInfo());
    }

    @Bean
    public Docket frontApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("frontApi").select().paths(Predicates.and(PathSelectors.regex("/front/.*"))).build().apiInfo(adminInfo());
//        return new Docket(DocumentationType.SWAGGER_2).groupName("adminApi").apiInfo(adminInfo());
    }

    private ApiInfo adminInfo() {
        return new ApiInfoBuilder().title("内测小游戏管理系统-API文档").description("本文档描述了内测小游戏管理系统接口").version("1.0").contact(new Contact("dq","www.baidu.com","1263184066@qq.com")).build();
    }

}
